package com.shhm.admin.controller;

import com.shhm.admin.service.UserRoleService;
import com.shhm.common.annotations.OperateLog;
import com.shhm.common.dto.request.RequestList;
import com.shhm.common.dto.request.admin.SysUserRoleReq;
import com.shhm.common.dto.response.AjaxResultPlus;
import com.shhm.common.dto.response.admin.SysUserRoleVO;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

/**
 * @author JackZ
 * @version 1.0
 * @description: TODO
 * @date 2025/8/14 下午5:24
 */
@RestController
@RequestMapping("/admin")
public class UserRoleController {
    @Resource
    private UserRoleService userRoleService;

    @GetMapping("/ur")
    public AjaxResultPlus pageList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            HttpServletRequest request
    ){
        return userRoleService.pageList(pageNum,pageSize,request);
    }

    @PostMapping("/ur/search")
    public AjaxResultPlus pageSearchList(
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize,
            @RequestBody SysUserRoleVO entity
    ){
        return userRoleService.pageSearchList(pageNum,pageSize,entity);
    }

    @PostMapping("/ur")
    @OperateLog(module="用户角色管理",type = "POST",desc = "添加系统用户角色信息")
    public AjaxResultPlus add(@RequestBody SysUserRoleReq entity){
        return userRoleService.add(entity);
    }

    @PutMapping("/ur")
    @OperateLog(module="用户角色管理",type = "PUT",desc = "修改系统用户角色信息")
    public AjaxResultPlus update(@RequestBody SysUserRoleReq entity){
        return userRoleService.update(entity);
    }

    @DeleteMapping("/ur")
    @OperateLog(module="用户角色管理",type = "DELETE",desc = "删除系统用户角色")
    public AjaxResultPlus delete(@RequestBody RequestList ids){
        return userRoleService.delete(ids);
    }
}
